package com.Home.Control;

import com.Home.Dao.Home.HomeListDao;
import com.Home.Dao.ImageDao;
import com.Home.Dao.Tag.OpertionOneDao;
import com.Home.Dao.Tag.OpertionTwoDao;
import com.Home.bean.BaseEnity;
import com.Home.bean.Home.HomeListEntity;
import com.Home.bean.ImageBean;
import com.Home.bean.Tag.BannerAndTagOneBean;
import com.Home.bean.Tag.TagOne;
import com.Home.bean.Tag.TagTwo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.awt.print.Pageable;
import java.util.List;

@RestController
public class ImageController {

    @Autowired
    private ImageDao imageDao;
    @Autowired
    private OpertionOneDao tagDao;

    @Autowired
    private OpertionTwoDao twoDao;
    @Autowired
    private HomeListDao homeListDao;

    //获取所有图片
    @RequestMapping(value = "/Image/getAll")
    public Object getImageAll(){
        List<ImageBean> list = imageDao.findAll();
        List<TagOne> all = tagDao.findAll();
        List<TagTwo> twoAll = twoDao.findAll();
        BannerAndTagOneBean banner = new BannerAndTagOneBean();
        banner.setBannerList(list);
        banner.setTagList(all);
        banner.setTagTwos(twoAll);
        BaseEnity<BannerAndTagOneBean> entity = new BaseEnity<BannerAndTagOneBean>();
        if(list == null){
            entity.setMsg("资源为找到");
            entity.setData(null);
            System.out.println("66666");
        }else{
            entity.setData(banner);
            entity.setCode(200);
            entity.setMsg("成功了");
            System.out.println("哇哈哈"+list.size());
        }
        return entity;
    }

    @RequestMapping(value = "/Home/getHomeList")
    public Object getHomeList(){
        List<HomeListEntity> all = homeListDao.findAll();

        BaseEnity<List<HomeListEntity>> entity = new BaseEnity<List<HomeListEntity>>();
        if(all == null){
            entity.setMsg("资源为找到");
            entity.setData(null);
            System.out.println("66666");
        }else{
            entity.setData(all);
            entity.setCode(200);
            entity.setMsg("成功了");
            System.out.println("tag"+all.size());
        }
        return entity;
    }
}
